var api = require("../../../../source/js/service.js")
avalon.component('ms-noticeBox',{
	template:require('./noticeBox.html'),
	defaults:{
		user:{},
		currType:'',
		noticelist:[],
		query:{
			PageSize:15,
			parentNoticeType:1
		},
		getNotices:function(){
			var that = this
			return api.getItems({
				method:api.getNotices,
				query:this.query
			},function(res){
				that.noticelist = res.data.list
			})
		},
		onInit:function(){
			// console.log('box')
			this.getNotices();
			var that = this
			this.$watch('currType',function(v){
				that.query.parentNoticeType=v;
				that.getNotices();
				that.user = {}
			})
			window.duxStore.subscribe(function(){
				if(that.user.name!=window.duxStore.getState().user.name&&window.duxStore.getState().user.name=='changeNoticesType'){
					that.user = window.duxStore.getState().user
					that.currType = window.duxStore.getState().user.setting
					// console.log(window.duxStore.getState().setting,'setting')
					console.log(that.currType)
				}
			})
		}
	}
})